const http = require('../../../utils/http.js');
const app = getApp()
const utils = require('../../../utils/util.js')
Page({
  data: {
    titleHeight: '',
    info: '',
    onUserWechat: false,
    statusd: 1,
    arlteViewStatus:true
  },
  onArlteView(){
    this.setData({
      arlteViewStatus:!this.data.arlteViewStatus
    })
  },
  onLoad: function (options) {
    var _this = this
    var query = wx.createSelectorQuery()
    query.select('#onPageView').boundingClientRect()
    query.select('#pageTitle').boundingClientRect()
    query.exec(function (res) {
      console.log(res)
      _this.setData({
        titleHeight: res[0].height - (res[1].height - 5)
      })
    })
    _this.onPageInfo()
  },
  /**
   * 获取导师图标的坐标
   */
  onBondMove(e){
    var _this = this
    console.log(e)
    if(e.touches[0].pageY < 200 || e.touches[0].pageY > 700){
      return false
    }
    _this.setData({
      teacherY:e.touches[0].pageY
    })
  },
  onReady: function () {},
  onShow: function () {},
  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {},
  onReachBottom: function () {},
  onShareAppMessage: function () {},
  onPageInfo() {
    var _this = this
    http.getRequest('v1/vip', {
      client_type:'3'},
      function (res) {
        console.log(res)
        try {
          res.data.member_oauth_info.expire_time = utils.formatTime(res.data.member_oauth_info.expire_time, 'Y-M-D h:m:s')
        } catch (error) {
          res.data.member_oauth_info = {expire_time:''}
        }

        _this.setData({
          info: res.data
        })
        setTimeout(() => {
          _this.setData({
            statusd: 0
          })
        }, 1000);
      },
      function (err) {
        setTimeout(() => {
          _this.setData({
            statusd: 0
          })
        }, 1000);
      })
  },
  onGoIsVipPlus(d) {
    var id = d.currentTarget.id
    if(id == 2){
      wx.navigateTo({
        url: '/pages/onNewPages/selfSupport/selfSupport?id=' + this.data.info.goods.tao_id,
      })
    }else{
      wx.navigateTo({
        url: '/pages/Login/getCode/getCode',
      })
    }
  },
  onShowUserWechat() {
    var _this = this
    _this.setData({
      onUserWechat: !_this.data.onUserWechat
    })
  },
  onCapy(e) {
    var _this = this
    wx.setClipboardData({
      data: e.currentTarget.id,
      success(res) {
        wx.getClipboardData({
          success(res) {
            _this.setData({
              onUserWechat: false
            })
          }
        })
      }
    })
  }
})